.messages {
    background: var(--content-bg);
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    border-radius: var(--screen-border-radius);
    overflow: hidden;
    height: 100%;
    min-height: 0;
}

.chat-messages {
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1 1 0;
    min-height: 0;
}

.chat-message {
    max-width: 85%;
    padding: 5px;
    border-radius: var(--border-radius);
    background: transparent;
    border: 1px solid orange;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    opacity: 1;
    transform: translateY(0);
    animation: messageSlideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 2px;
    border: 1px solid orange;
    overflow: hidden;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.message-content-wrapper {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.message-time {
    font-size: 0.8em;
    color: var(--screen-text-color);
    opacity: 0.7;
}

.reply-button {
    background: transparent;
    border: 1px solid orange;
    color: orange;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7em;
    cursor: pointer;
    margin-left: auto;
}

.reply-button:hover {
    background: orange;
    color: black;
}

.reply-indicator {
    font-size: 0.8em;
    color: var(--screen-text-color);
    opacity: 0.7;
    margin-bottom: 5px;
    font-style: italic;
}

.reply-indicator[data-reply-to]:hover {
    opacity: 1;
    color: orange;
    text-decoration: underline;
}

.message-highlight {
    background: rgba(255, 165, 0, 0.3) !important;
    border: 2px solid orange !important;
    animation: highlightPulse 2s ease-in-out;
}

@keyframes highlightPulse {
    0%,
    100% {
        background: rgba(255, 165, 0, 0.3);
        transform: scale(1);
    }
    50% {
        background: rgba(255, 165, 0, 0.5);
        transform: scale(1.02);
    }
}

.reply-indicator-input {
    background: var(--content-bg);
    border: 1px solid orange;
    padding: 5px 10px;
    margin-bottom: 10px;
    border-radius: 3px;
    font-size: 0.8em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cancel-reply-btn {
    background: none;
    border: none;
    color: orange;
    cursor: pointer;
    font-size: 1.2em;
    padding: 0;
    margin-left: 10px;
    transition: color 0.2s ease;
}

.cancel-reply-btn:hover {
    color: #ff6600;
}

.chat-message.own {
    align-self: flex-end;
    border-color: lime;
    background: rgba(0, 255, 0, 0.05);
}

.chat-message.other {
    align-self: flex-start;
    border-color: orange;
}

.message-content {
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
    max-width: 100%;
    box-sizing: border-box;
}

.chat-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 15px;
}

.input-wrapper {
    flex: 1;
    position: relative;
    display: inline-block;
    border-radius: 2px;
    padding: 5px;
    z-index: 0;
    min-width: 0;
    max-width: 100%;
    border: var(--main-border);
}

#chatInput {
    font-family: var(--screen-font-family);
    font-size: var(--main-font-size);
    border-radius: 2px;
    background-color: var(--content-bg);
    color: var(--screen-text-color);
    overflow-y: auto;
    overflow-x: hidden;
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
    resize: none;
}

#chatInput:focus {
    outline: none;
}

#chatInput:empty::before {
    content: attr(data-placeholder);
    color: var(--screen-text-color);
    font-size: var(--main-font-size);
    opacity: 0.7;
    pointer-events: none;
}

#chatInput:focus:empty::before {
    opacity: 0.5;
}

.send-btn {
    color: var(--screen-text-color);
    background: transparent;
    font-size: 1rem;
    width: 32px;
    height: 32px;
    cursor: pointer;
    border-radius: 50%;
    border: 1px solid orange;
}

.send-btn:hover {
    background: lime;
    color: orange;
}

.send-btn:disabled {
    cursor: not-allowed;
}

.sticker-btn {
    border: 1px solid orange;
    color: transparent;
    cursor: pointer;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    background-image: url('/Assets/Pictures/Skins/oiia.png');
    background-color: lime;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.sticker-picker {
    background: #d4ffc2;
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    border: var(--main-border);
    border-radius: 0.75em;
    max-height: 300px;
    overflow-y: auto;
    padding: 16px;
    margin-bottom: 8px;
    z-index: 10;
    display: none;
    overflow: auto;
}

.sticker-picker.show {
    display: block;
}

.sticker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
}

.sticker-option {
    width: 60px;
    height: 60px;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    border: var(--main-border);
}

.sticker-option:hover {
    border-color: lime;
    transform: scale(1.1);
}

.sticker-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sticker-message {
    max-width: 150px;
}

.sticker-message img {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Chat Help Button */

.header-icons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.help-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: 1px solid orange;
    color: orange;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.2s ease;
}

.help-button:hover {
    background: orange;
    color: black;
    transform: scale(1.1);
}

/* Chat Help Modal */

.chat-help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.chat-help-modal.show {
    display: flex;
}

.chat-help-content {
    background: var(--content-bg);
    border: var(--main-border);
    border-radius: var(--border-radius);
    padding: 30px;
    max-width: 500px;
    max-height: 70vh;
    overflow-y: auto;
    color: var(--screen-text-color);
    font-family: var(--screen-font-family);
}

.chat-help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid orange;
    padding-bottom: 10px;
}

.chat-help-header h3 {
    margin: 0;
    color: orange;
    font-size: 1.2em;
}

.chat-help-close {
    background: transparent;
    border: 1px solid orange;
    color: orange;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2em;
}

.chat-help-close:hover {
    background: orange;
    color: black;
}

.chat-help-section {
    margin-bottom: 20px;
}

.chat-help-section h4 {
    color: lime;
    margin-bottom: 10px;
    font-size: 1em;
}

.chat-help-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chat-help-section li {
    padding: 5px 0;
    border-left: 2px solid orange;
    padding-left: 10px;
    margin-bottom: 5px;
    font-size: 0.9em;
    line-height: 1.4;
}

.chat-help-legal {
    font-size: 0.8em;
    color: var(--screen-text-color);
    opacity: 0.7;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 165, 0, 0.3);
    line-height: 1.3;
}

/* Scrollbar Styles */

.sticker-picker::-webkit-scrollbar {
    display: none;
}

.leaderboard-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.leaderboard-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.leaderboard-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: #4d991f;
}

.leaderboard-list::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #4d991f;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-secondary);
    text-align: center;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.chat-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-secondary);
    text-align: center;
}

.loading-oiia {
    width: 80px;
    height: 80px;
    margin-bottom: 1rem;
    border-radius: 50%;
}

.chat-loading-state p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Chat error toast */

.chat-error-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(220, 53, 69, 0.95);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    max-width: 90%;
    text-align: center;
}

.chat-error-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}